#fortran 90 do loop
Explore tagged Tumblr posts
techtutor · 7 years ago
Video
youtube
FORTRAN program which calculates up to six decimal places of 1+1/3+1/5+-...
0 notes
yuckitup-jwd · 5 years ago
Text
Fulldeckisms Part 3
One shot short of a chain. (Shot is a section of anchor chain.)
One shot short of a locker. (Shot is ammunition; a locker iswhere it's stored.)
One shrimp short of a barbie.
One side short of a pentagon.
One signature short of a book.
One slate short of a full roof.
One sleeve/button short of a shirt.
One snowflake short of a ski slope.
One sock short of a pair.
One song short of a musical.
One span short of a bridge.
One spoon short of a full set.
One steering wheel / bolt short of a Yugo.
One step short of the attic.
One stick short of a bundle.
One straw short of a bale.
One strawberry short of a quart.
One strike past being called out.
One sub short of a party platter.
One taco/enchilada/chalupa short of a combination/Mexican plate.
One teabag short of a pot.
One tilde short of a full URL.
One tile missing from his space shuttle.
One tile short of a successful re-entry.
One too many lights out in his Christmas tree.
One too many rides on the Zipper.
One tower short of a castle.
One tree short of a hammock.
One vine short of the tree. (For Tarzan types.)
One volt below threshold.
One weight short of a shipwreck.
One word short of a.
One yard short of the hole.
Only occasionally wets himself under pressure.
Only one oar in the water.
Only opens his mouth to change feet.
Only playing with 51 cards.
Only playing with the jokers.
Operating in stand-by mode.
Organizationally impaired.
Ought to have a warning label on his forehead.
Out of his depth in a parking lot puddle.
Out there where the buses don't run.
Outlet isn't grounded.
Over the rainbow.
Overdue for reincarnation.
Overruns above 110 baud.
Paged/swapped out.
Parallel mind, serial world.
Parallel world, serial mind.
Paralyzed from the neck up.
Parents beat him with an ugly stick.
Parked his head and forgot where he left it.
Pedaling real fast, but not getting anywhere.
People around her are at risk of second hand idiocy.
Perfect chassis, bad driver.
Perfect face for Halloween.
Perfect percussionist for an acapella group (duh, duh, duh...)
Perfect training subject for apprentice hypnotists.
Permanently out to lunch.
Permanently rotated 90 degrees from the rest of us.
Phototrophic on a better day.
Pins 2 and 3 (RS-232) permanently connected to ground.
Playing an endgame with a king and no other pieces.
Playing baseball with a rubber bat.
Playing hockey with a warped puck.
Playing Scrabble, but we can't figure out what words he's building.
Plays pinochle with a poker deck.
Plays solitaire... For cash.
Plays tennis with no net and finds it challenging.
Plenty of myelin but not enough neurons.
Plenty of salt in the shaker, but no holes in the cap.
Posts empty articles to the Net, and enjoys rereading them later.
Prefers three left turns to one right turn.
Pressure's up, but there's a slow leak somewhere.
Pretty as 20 miles of bad road.
Produces a zero-length core dump.
Programmed into an infinite loop.
Proud of his lawn mower.
Psycho pneumatic. (Crazy air head.)
Put a lens in each ear and you've got a telescope.
Put on Earth to be an oxygen converter.
Puts a finger in his ear so the draft through his head isn't annoying.
Putting his brain on the edge of a razor blade would be likeputting a pea on a six lane highway.
Qualifies for the mental express line -- five thoughts orless. -- MacNelly
Quotes entire letters/articles as responses and hides her oneline of wisdom in the middle.
Racing fifty yards with a pregnant woman, he'd come in third.
Radio's playing but nobody's listening.
Reading from an empty/blank/unformatted disk.
Reads her newspaper back-to-front.
Reads Homer in the original Greek, but doesn't know Greek.
Ready to check in at the HaHa Hilton.
Ready to join the Anti-Mensa Society.
Receiver is off the hook.
Relatively three-dimensional, as fictional characters go.
Renewable energy source for hot air balloons.
Reposts this list when someone asks for it, but it's an old copy.
Requires retraining after every coffee break.
Reset line is glitching.
Result of a first cousin marriage.
Result of God's experiments to see if humans can functionwithout a brain.
Room for rent, unfurnished.
Roving target for a surface-to-idiot missile.
RS232C brain with a DIN connector.
Running at 300 baud.
Running lights are on but no one's at the helm.
Running on a 286.
Running open. (Old mechanical teletype term.)
Running U.S. appliances on British current.
Runs squares around the competition.
Rusty springs in the mousetrap.
S p a c e d o u t .
Sailboat fuel for brains.
Sailing with a short seabag / a few skivvies short of a seabag.(Contains all of a sailor's possessions including underwear.)
Sat under the ozone hole too long.
Says profound things but no one listens and no harm is done.
Seen it all, done it all, can't remember most of it.
Sending back packets, but the checksums are wrong.
Serving donuts on another planet.
Settled some during shipping and handling.
Seven cans short of a six-pack.
Seven seconds behind, and built to stay that way.
Several nuts over fruitcake minimum.
Sharp, like stone in river. Swift, like tree through forest.
She believes the three great lies.
She can piss standing up, but not much else.
She doesn't suffer from insanity; she enjoys every minute of it.
She fears success, but really has nothing to worry about. -- Thaves
She has reached rock bottom, and has started to dig.
She looks virtually real today.
She only packed half a sandwich.
She only schedules zombie processes.
She put the ding in dingbat.
She runs the gamut of emotions from A to B. -- Dorothy Parker
She sets low personal standards and then consistently fails them.
She sounds reasonable... Must be time to up my medication.
She stopped to think and forgot to start again.
She wears a pony tail to cover up the valve stem.
She worries about the calories licking stamps and envelopes.
She'll be just fine as soon as virtual reality arrives.
She's a screensaver. (Looks good, but useless.)
She's all thumbs.
She's as daft as a brush. (British)
She's running real fast, but toward the wrong goal line.
Shedding a little too much black light.
Short a few cards.
Short-circuited between the earphones.
Should be the poster child for family planning.
Should go far -- and the sooner he starts, the better.
Should have kept his helmet on while riding/playing.
Shouldn't be allowed to breed.
Shouldn't eat nuts -- for her, it's practically cannibalism.
Single-sided, low density.
Sings along with elevator music.
Sinking with a deck full of people; her brain cells can'tfind the lifeboats.
Sitting in the right pew, but the wrong church.
Six-packed seven times. (Volleyball slang: "Six-pack" is tospike someone in the head with a volleyball.)
Skating on the wrong side of the ice.
Skylight leaks a little.
Slept too close to his radium-dial watch.
Slinky's kinked.
Sloppy as a soup sandwich.
Slow as molasses in January.
Slow out of the gate.
Slower than a herd of turtles stampeding through peanut butter.
Smarter than the average bear.
Smoke doesn't make it to the top of his chimney.
So boring, his dreams have Muzak.
So clueless, he could BE God and still be an atheist.
So dim, his psychic carries a flashlight.
So dumb, blondes tell jokes about him.
So dumb, he faxes face up.
So dumb, he puts postage stamps on outgoing faxes.
So dumb, his dog teaches him tricks.
So far gone, hard drugs push him closer to normal.
So fat, people jump over him rather than go around.
So slow, he has to speed up to stop.
So slow, we drive stakes in the ground to measure his progress.
So stupid, he tries to drown fish.
So stupid, mind readers charge her half price.
So stupid, she doesn't go further than Thursday.
So thick, he sticks to pasta.
So ugly, robbers give him their masks to wear.
Sold his car for gas money.
Solid concrete from the eyebrows backwards.
Some Assembly Required.
Some bugs in his software.
Some drink from the fountain of knowledge, but he just gargled.
Some of her inodes have nodded off.
Some pages missing.
Somebody lend her a quarter to buy a clue.
Somebody put a stop payment order on his reality check.
Someday when she's younger, she'll ________.
Someone blew out his pilot light.
Someone else is doing the driving for that boy.
Someone forgot to plant the seed for his brain stem.
Someone let the air out of her lock.
Someone Reverend Spooner would have identified as a shining wit.
Sort of like an inverse Einstein.
Source code is missing a few lines.
Speaks math/FORTRAN better than English.
Spent a decade on the leading edge of drug experimentation.
Stares at frozen juice cans because they say, "concentrate".
Still boots to DOS.
Still sending messages with his secret decoder ring.
Still struggling up the evolutionary ladder.
Still traumatized from the forest fire in "Bambi".
Still trying to figure out opposable thumbs.
Stocksy-babes. (A truly vile British-slang insult.)
Strolling through life with one shoelace untied.
Strong, like bull. Smart, like tractor. Beautiful, like KV-2.(A WWII era Russian tank.)
Stuck on the down escalator of life.
Studied for a blood test -- and failed.
Stumped by anything child-proof.
Subtle as a well-thrown brick.
Subtle as a wet tongue in the ear / kiss from a cow.
Suffers from Clue Deficit Disorder.
Suffers from excessive headspace.
Suffers from link rot. (The process by which hypertext linksbecome obsolete as their sites change or die.)
Suffers from Paralysis by Analysis.
Suffers from permanent rapture of the deep. (Nitrogen narcosis.)
Supports nativist theories that man is formed from clay.
Surfing in Nebraska.
Surfing the Web with a hard-copy terminal. (Does anyoneremember those?)
Suspend switch is jumpered.
Swimming on a cold shot. (Inadequate ejection force for a torpedo.)
Switch is on, but no one's receiving.
Takes her 1.5 hours to watch "60 Minutes".
Takes her an hour to cook minute rice.
Takes his imagination out for a walk and ends up being draggedaround the block by it.
Talking with her is a career-limiting move.
Talking with him is a waste of good bandwidth.
Talks to plants on their own level.
Tall as a post and just as smart.
Team player... No chance he'll develop a personality on his own.
Technically sound, but socially impossible.
Teflon brain -- nothing sticks. -- Lilly Tomlin
Ten to the dozen.
The aliens forget to remove his anal probe.
The bark on her family tree actually involves canines.
The best part of him ran down his mother's legs. -- Jackie Gleason
The butter slipped off his noodle.
The cheese slid off his cracker.
The definitive answer is: Her glass is half empty.
The fan is working but the freon's leaked out.
The fire is going well, but the flue is closed.
The going got weird, and he turned pro.
The heater's plugged in but the rheostat's shot.
The march of his intellect is like that of a crab, backward.-- Peacock
The most rock-hard argument can crash through his airy head andcause only the slightest disturbance in the air currentsthat surround the void that comprises his knowledge.
The only place she's ever invited is outside.
The perfect personality to write software manuals.
The recesses of his mind are always in recess.
The result of years of careful inbreeding.
The sharpest thing he's allowed to play with is a red rubber ball.
The space between his ears powers vacuum pumps.
The spit valve's fallen off his trumpet again.
The twinkle in his eyes is actually the sun shining between his ears.
The two put together have an IQ over 150.
The wheel's spinning but the hamster's dead.
The world's foremost collector of ignorance.
Their family tree is a tumbleweed.
There are great people in the world, but she's not one of them.
There she sits, Finite State Automation at its best.
There's no ice cubes in THAT tray. -- Second City comedy troupe
There's nothing wrong with you that couldn't be cured witha little Prozac and a polo mallet. -- Woody Allen
They had to burn down the school to get her out of third grade.
They must have done a clean boot on him.
They never shut up on his planet.
Thick as a brick / whale omelette.
Thick as pig dung and twice as smelly.
Thinks "Private Enterprise" means owning a personal starship.
Thinks a permutation is a medical procedure.
Thinks at 5 baud.
Thinks cellular phones are carbon-based life forms.
Thinks Cheerios are doughnut seeds.
Thinks E=MC^2 is a rap star.
Thinks everyone else is entitled to his opinion, like it or not.
thinks in lower case & types accordingly
Thinks like a boar hog looks at a wristwatch.
Thinks male zebras are the ones with the black stripes.
Thinks Moby Dick is a kind of venereal disease.
Thinks Taco Bell is where you pay for your phone calls to Mexico.
Thirteen short of a dozen.
Three sigma off the norm.
Three-bag/coyote ugly. (Ask your mommy to explain.)
Throws his rod and reel off the bridge when casting.(I resemble that remark. -- editor)
Tight / waterproof as a fish's sphincter.
Tight as a bull's arse in fly season.
To make him laugh on Saturday, tell him a joke on Wednesday.
Tone arm is down but no music is playing.
Too dumb to be bothered when publicly displaying her ignorance.
Too dumb to know when you're getting smart / playing dumb with him.
Too many bad drugs, not enough good drugs.
Too many birds on her antenna.
Too many jokers and not enough aces in his deck.
Too many stop bits in his transmissions.
Too much yardage between the goal posts.
Too pointless to even be called a pinhead.
Top paddock is full of rocks.
Toys in the attic.
Train of thought derailed / still boarding at thestation / has no caboose.
Traveling faster than light, but left his sneakers behind.
Traveling without a passport/towel.
Tried welding two 2x4s together and burned down his house.
Tries to forward this list to some friends, but instead shipssix copies of it to the editor (groan).
Trips over cordless phones.
Truck can't haul a full load.
Truly believes "neural network" is a new Ted Turner enterprise.
Trying out for the javelin retrieval team.
Tuning in shortwave with a TV antenna.
Two bits short of a word/dollar.
Two degrees off square.
Two inches taller than spherical.
Types 120 words a minute but her keyboard isn't plugged in.
Uglier than a hat full of assholes. (Whatever that means.)
Ugly as a warthog and half as smart.
Unclear which of Newton's three laws of motion keeps his ears apart.
Understands English as well as any parrot.
Used to have a handle on life, but it broke.
Useful as dinosaur repellent.
Useful as passing gas in a spacesuit.
Useful as piss on a forest fire.
Useful as tits on a bullfrog / bull / boar-hog.
Uses all three functional neurons for his best work.
Uses AOL.
Uses his head best for rolling Easter eggs.
Uses his head to keep the rain out of his neck.
Uses thumbtacks to post notes -- on his refrigerator.
Uses two hands to eat with chopsticks.
Using a 1S-2D floppy for brains in a world of hard disks.
Vacancy on the top floor.
Vacuuming linoleum using a deep-pile setting. (Not pickingup anything.)
Vaginally challenged, and preoccupied with the problem.
Validates my inherent mistrust of strangers.
Vegitatum davenportae. (Couch potato.)
Vertically-fornicated mind.
Views mold as a higher life form.
Vowel-buyer. (As on the TV show Wheel of Fortune, when thesolution is already obvious.)
Waiting on a toaster that's not plugged in.
Warning: Objects in her mirror are dumber than they appear.
Warranty expired.
Was assimilated by the Borg.
Was born an acrobat but landed on his head.
Was born when the planets were misaligned.
Was first in line for brains, but ended up holding the door open.
Was left on the Tilt-A-Whirl a bit too long as a baby.
Was napping in the nut pile the day God was cracking nuts.
Wasn't abused as a child, but should have been.
Wasn't fully debugged before being released.
Wasn't strapped in during launch.
Watches "Beavis and Butthead" to learn vocabulary.
Watching programs not listed in TV Guide.
We're all missing cards from our decks -- and different cards, too.
We're all refreshed and challenged by her unique point of view.
Went in for repairs but wasn't tightened with a torque wrench.
Went to the dentist to have his cranial cavity filled.
Whatever kind of look she was going for, she missed.
When a thought crosses her mind, it's a long and lonely journey.
When God said, "Come forth for brains," he came fifth.
When he collects his thoughts, they fit in a verysmall container. -- Bob Thaves
When he was compiled they forgot to #include<smarts.h>/<iq.h>/<charm.h>.
When her window of opportunity opened, she had the shade drawn.
When opportunity knocked, she refused to open the door.
When she dances, she makes the band skip.
When she hauls ass, she has to make two trips.
When she puts on her lipstick, it keeps backing down the tube.-- Kevin Wilson
When she was born the doctor tried to kill her / slapped her mother.
When they handed out brains he got the short end of the stick / wasat the end of the line.
When they said "drain", he thought they said "brain".
Where it says, "Sign here", she writes, "Pisces".
While he was not dumber than an ox, he wasn't any smarter. -- Thurber
Whole lotta choppin', but no chips a flyin'.
Will never get a ticket for speeding.
Wise as the world is flat.
With one more neuron he'd have a synapse.
Won't eat eggs because he believes the "This is your brain" ads.
Works well when under constant supervision and corneredlike a rat in a trap.
Would make an excellent illustration in a proctology textbook.
Would need help to drool.
Would starve to death in a grocery store.
Wouldn't know a tram was up him if the conductor rang hisbell. (Australian)
Wouldn't know ore if it jumped out of the stope and bithim on the ass. (Said of mineral prospectors.)
Wouldn't make any sense if she ever made sense.
Wouldn't recognize a clue if he saw one / you showed himone (labelled "clue").
Wouldn't shout if a shark bit him. (Australianism meaning hewon't buy a round of drinks (shout) in turn.)
You can hardly tell that he's a simulation.
Zero K memory.
0 notes
siva3155 · 6 years ago
Text
300+ TOP FORTRAN Objective Questions and Answers
FORTRAN Multiple Choice Questions :-
1. Which of the following is not a valid property of a PARAMETER statement? A. Can combine other parameters with FORTRAN arithmetic operators to compute the value of a new parameter B. Parameters can be set anywhere in a program C. Integer parameters can be used to set array dimensions D. Parameters can be used as bounds on do loops. Ans: B 2. For the following FORTRAN operations give the rank from fastest to slowest in terms of computer time required A. x*0.5 B. x+0.5 C. x**0.5 D. sqrt(x) Ans: C 3. Which of the following is not a valid property of a PARAMETER statement? A. Can combine other parameters with FORTRAN arithmetic operators to compute the value of a new parameter B. Parameters can be set anywhere in a program C. Integer parameters can be used to set array dimensions D. Parameters can be used as bounds on do loops. Ans: B 4. In a FORTRAN program I have set x=2.0, a=2.0 and b=4.0. What is the value of y if: y = a*x+b**2/x ? A. 8.0 B. 12.0 C. 16.0 D. 64.0 Ans: B 5. In a FORTRAN program I have set x=1.5,i=3, and j=2. What is the value of y if: A. 3.0 B. 3.5 C. 4.0 D. 4.5 Ans: C 6. In a FORTRAN program x=4.5, y=3.0, and w=1.5, What is the value of z if: z = x+w/y+1 A. 1.5 B. 3.0 C. 4.5 D. 6.0 Ans: D 7. In a FORTRAN program x=1.0, y=2.0 and w=3.0. What is the value of z if: z=2.0(x(y+3.0)+w) A. 12.0 B. 16.0 C. 18.0 D. not determined due to a FORTRAN syntax error Ans: D 8. After compiling the FORTRAN statement: y = c/d + a*x**2-5 Which operation is performed first by the computer? A. / B. + C. * D. ** Ans: D 9. For the following FORTRAN operations give the rank from fastest to slowest in terms of computer time required: 1)x*0.5 2)x+0.5 3)x**0.5 4)sqrt(x) A. 1-2-3-4 B. 1-2-4-3 C. 2-1-3-4 D. 2-1-4-3 Ans: D 10. On the Hammond machines, a single percision floating point (REAL*4) number uses how many bits of memory? A. 4 B. 7 C. 15 D. 32 Ans: D
Tumblr media
FORTRAN MCQs 11. A number stored in Double Precision Floating Point (REAL*8) format can have at most approximately how many decimal digits of precision? A. 3 B. 7 C. 31 D. 15 Ans: D 12. A real number established with "selected_real_kind(6,30)" uses how many bits? A. 4 B. 6 C. 30 D. 32 Ans: D 13. What is the first number in the following list that can not be represented with a Fortran INTEGER*4 ( the default setting on the Hammond machines )data type? A. 0 B. 1025 C. 2,000,000 D. 2,000,000,000,000 Ans: D 14. What is the first number in the following list that can not be represented with a FORTRAN REAL*8 ( Double Precision ) variable? A. -3.0*1050 B. 3.0*101000 C. 3.0*10-80 D. 3.0*10100 Ans: B 15. Which of the following is an "executable" statement (takes an action when "a.out" is executed)? A. ALLOCATE B. DIMENSION C. EXTERNAL D. PARAMETER Ans: A 16. Which of the following is an executable statement ( takes action when "a.out" is executeed)? A. INTRINSIC B. DIMENSION C. EXTERNAL D. CLOSE Ans: D 17. A FORTRAN WHERE statement: A. Provides the current line number in the input file being processed B. Returns the name of the current Subroutine or Function C. Conditionally executes one or more Fortran 90 vector (array) statements D. Provides the current cursor position on the terminal screen Ans: C FORTRAN Objective type Questions with Answers 18. The statement "read(10,end=100) mm " will: A. branch to the statement with label 100 when the end of the file is reached on unit 10 B. branch to the statement label with 100 when the struing "end" is read from unit 10 C. branch to the end of the program when a value of 100 is read from unit 10 D. Set the variable mm = 100 when the end of the file is reached Ans: A 19. Which of the following statements is a valid way to open the file test.data and associate it with unit 10? A. open(10,test.data) B. open(10,'test.data') C. open(10, file= test.data ) D. open(10,file='test.data') Ans: D 20. On the Hammond machines, a single percision floating point (REAL*4) number uses how many bits of memory? A. 4 B. 7 C. 32 D. 15 Ans: D 21. What are the basic datatypes in Fortran? A. Integer, Real, Double Precision, Character B. Integer, Real, Character, Logical C. INteger, Real, Complex, Character Ans: B 22. In which column does the code start in Fortran 77 fixed format? A. 6 B. 9 C. 7 Ans: C 23. What signals a comment in Fortran 95? A. An exclamationmark ! anywhere on the line B. A C in column one C. An asterisk * in column six? Ans: A 24. How can we continue source code from one line to the next in Fortran 95? A. by an asterisk * in column 6 B. An ampersand & at the end of a line C. By using brackets Ans: B 25. What is the purpose of a number in column 2 to 5 in Fortran 77 fixed format A. A jump label or format label B. Just a jump label C. Just a format label Ans: A 26. Which of the following is not a valid property of a PARAMETER statement? A. Can combine other parameters with FORTRAN arithmetic operators to compute the value of a new parameter B. Parameters can be set anywhere in a program C. Integer parameters can be used to set array dimensions D. Parameters can be used as bounds on do loops. E. Can be passed as arguments to subroutines Ans: B 27. In a FORTRAN program I have set x=2.0, a=2.0 and b=4.0. What is the value of y if: y = a*x+b**2/x ? A. 8.0 B. 12.0 C. 16.0 D. 32.0 E. 64.0 Ans: B 28. In a FORTRAN program I have set x=1.5,i=3, and j=2. What is the value of y if: y = 2*x + i/j A. 3.0 B. 3.5 C. 4.0 D. 4.5 E. 5.0 Ans: C 29. In a FORTRAN program x=4.5, y=3.0, and w=1.5, What is the value of z if: z = x+w/y+1 A. 1.5 B. 3.0 C. 4.5 D. 6.0 Ans: D 30. not determined due to a Fortran Syntax error In a FORTRAN program x=1.0, y=2.0 and w=3.0. What is the value of z if: z=2.0(x(y+3.0)+w) A. 12.0 B. 16.0 C. 18.0 D. 22.0 E. not determined due to a FORTRAN syntax error Ans: E 31. After compiling the FORTRAN statement: y = c/d + a*x**2-5 Which operation is performed first by the computer? A. / B. + C. * D. ** E. - Ans: D 32. When using vi, which of the following commands will delete a full line? A. d B. dd C. dl D. r E. x Ans: B 33. The command " man ls > more " will: A. Provide help on the command "ls" as text in a file called "more" B. Provide help on the command "ls" viewed with the utility "more" C. Provide help on commands alphabetically between ls and more D. Provide a more detailed help on the command "ls" than is usually given E. Result in a system message: "Command not found" Ans: A 34. When working on a Unix workstation without any special aliases, which of the following commands should be used to delete a file? A. del B. dd C. df D. rf E. rm FORTRAN Questions and Answers pdf Download Read the full article
0 notes
ltslearn-blog · 8 years ago
Text
C Programming C is a general-purpose, procedural computer programming language which is still in regular use over four decades after its creation. It was developed in 1972 by Dennis Ritchie and Brian Kernighan (then of Bell Laboratories) for use with the Unix operating system, and was documented, before it entered the standards process, in a 1978 reference book commonly referred to as the Kernighan and Ritchie book, or just K&R. The language has been implemented for many different computer platforms and eventually became standardized by ANSI and ISO--there is a Second Edition of K&R using the ANSI standard syntax. Although superseded by more modern languages for general application programming, since 2010 versions of C are still being used, primarily for writing operating system software and embedded programs (for gadgets such as smart phones). C and its closely related sister language, C++, are also used for games development and other graphics- or media-intensive programming. Although once used for web programming, it has been superseded for web programming by newer languages that provide more security and which enforce safer programming practices. How is the World Powered by C? Despite the prevalence of higher-level languages, C continues to empower the world. The following are some of the systems that are used by millions and are programmed in the C language. Microsoft Windows Microsoft’s Windows kernel is developed mostly in C, with some parts in assembly language. For decades, the world’s most used operating system, with about 90 percent of the market share, has been powered by a kernel written in C. Linux Linux is also written mostly in C, with some parts in assembly. About 97 percent of the world’s 500 most powerful supercomputers run the Linux kernel. It is also used in many personal computers. Mac Mac computers are also powered by C, since the OS X kernel is written mostly in C. Every program and driver in a Mac, as in Windows and Linux computers, is running on a C-powered kernel. Mobile iOS, Android and Windows Phone kernels are also written in C. They are just mobile adaptations of existing Mac OS, Linux and Windows kernels. So smartphones you use every day are running on a C kernel. Embedded Systems Imagine that you wake up one day and go shopping. The alarm clock that wakes you up is likely programmed in C. Then you use your microwave or coffee maker to make your breakfast. They are also embedded systems and therefore are probably programmed in C. You turn on your TV or radio while you eat your breakfast. Those are also embedded systems, powered by C. When you open your garage door with the remote control you are also using an embed  ded system that is most likely programmed in C. Then you get into your car. If it has the following features, also programmed in C: • automatic transmission • tire pressure detection systems • sensors (oxygen, temperature, oil level, etc.) • memory for seats and mirror settings. • dashboard display • anti-lock brakes • automatic stability control • cruise control • climate control • child-proof locks • keyless entry • heated seats • airbag control You get to the store, park your car and go to a vending machine to get a soda. What language did they use to program this vending machine? Probably C. Then you buy something at the store. The cash register is also programmed in C. And when you pay with your credit card? You guessed it: the credit card reader is, again, likely programmed in C. Syntax C has a formal grammar specified by the C standard. Line endings are generally not significant in C; however, line boundaries do have significance during the preprocessing phase. Comments may appear either between the delimiters /* and */, or (since C99) following // until the end of the line. Comments delimited by /* and */ do not nest, and these sequences of characters are not interpreted as comment delimiters if they appear inside string or character literals. C source files contain declarations and function definitions. Function definitions, in turn, contain declarations and statements. Declarations either define new types using keywords such as struct, union, and enum, or assign types to and perhaps reserve storage for new variables, usually by writing the type followed by the variable name. Keywords such as char and int specify built-in types. Sections of code are enclosed in braces ({ and }, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures. As an imperative language, C uses statements to specify actions. The most common statement is an expression statement, consisting of an expression to be evaluated, followed by a semicolon; as a side effect of the evaluation, functions may be called and variables may be assigned new values. To modify the normal sequential execution of statements, C provides several control-flow statements identified by reserved keywords. Structured programming is supported by if(-else) conditional execution and by do-while, while, and for iterative execution (looping). The for statement has separate initialization, testing, and reinitialization expressions, any or all of which can be omitted. break and continue can be used to leave the innermost enclosing loop statement or skip to its reinitialization. There is also a non-structured goto statement which branches directly to the designated label within the function. Switch selects a case to be executed based on the value of an integer expression. Expressions can use a variety of built-in operators and may contain function calls. The order in which arguments to functions and operands to most operators are evaluated is unspecified. The evaluations may even be interleaved. However, all side effects (including storage to variables) will occur before the next "sequence point"; sequence points include the end of each expression statement, and the entry to and return from each function call. Sequence points also occur during evaluation of expressions containing certain operators (&&, ||, ?: and the comma operator). This permits a high degree of object code optimization by the compiler, but requires C programmers to take more care to obtain reliable results than is needed for other programming languages. Kernighan and Ritchie say in the Introduction of The C Programming Language: "C, like any other language, has its blemishes. Some of the operators have the wrong precedence; some parts of the syntax could be better. The C standard did not attempt to correct many of these blemishes, because of the impact of such changes on already existing software. Character set The basic C source character set includes the following characters: • Lowercase and uppercase letters of ISO Basic Latin Alphabet: a–z A–Z • Decimal digits: 0–9 • Graphic characters: ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~ • Whitespace characters: space, horizontal tab, vertical tab, form feed, newline Newline indicates the end of a text line; it need not correspond to an actual single character, although for convenience C treats it as one. Additional multi-byte encoded characters may be used in string literals, but they are not entirely portable. The latest C standard (C11) allows multi-national Unicode characters to be embedded portably within C source text by using \uXXXX or \UXXXXXXXX encoding (where the X denotes a hexadecimal character), although this feature is not yet widely implemented. The basic C execution character set contains the same characters, along with representations for alert, backspace, and carriage return. Run-time support for extended character sets has increased with each revision of the C standard. Reserved words C89 has 32 reserved words, also known as keywords, which are the words that cannot be used for any purposes other than those for which they are predefined: auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while C99 reserved five more words: _Bool _Complex _Imaginary inline restrict C11 reserved seven more words: _Alignas _Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local Most of the recently reserved words begin with an underscore followed by a capital letter, because identifiers of that form were previously reserved by the C standard for use only by implementations. Since existing program source code should not have been using these identifiers, it would not be affected when C implementations started supporting these extensions to the programming language. Some standard headers do define more convenient synonyms for underscored identifiers. The language previously included a reserved word called entry, but this was seldom implemented, and has now been removed as a reserved word. Operators Main article: Operators in C and C++ C supports a rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expression. C has operators for: • arithmetic: +, -, *, /, % • assignment: = • augmented assignment: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>= • bitwise logic: ~, &, |, ^ • bitwise shifts: <<, >> • boolean logic: !, &&, || • conditional evaluation: ? : • equality testing: ==, != • calling functions: ( ) • increment and decrement: ++, -- • member selection: ., -> • object size: sizeof • order relations: <, <=, >, >= • reference and dereference: &, *, [ ] • sequencing: , • subexpression grouping: ( ) • type conversion: (typename) C uses the operator = (used in mathematics to express equality) to indicate assignment, following the precedent of Fortran and PL/I, but unlike ALGOL and its derivatives. C uses the operator == to test for equality. The similarity between these two operators (assignment and equality) may result in the accidental use of one in place of the other, and in many cases, the mistake does not produce an error message (although some compilers produce warnings). For example, the conditional expression if(a==b+1) might mistakenly be written as if(a=b+1), which will be evaluated as true if a is not zero after the assignment. The C operator precedence is not always intuitive. For example, the operator == binds more tightly than (is executed prior to) the operators & (bitwise AND) and | (bitwise OR) in expressions such as x & 1 == 0, which must be written as (x & 1) == 0 if that is the coder's intent. What are the disadvantages of C Programming Language • C Programming Language doesn't support Object Oriented Programming (OOP) features like Inheritance, Encapsulation, Polymorphism etc. It is a procedure oriented language. In C, we have to implement any algorithms as a set of function calls. • C doesn't perform Run Time Type Checking. It only does compile time type checking. At run time, C doesn't ensure whether correct data type is used instead it perform automatic type conversion. • C does not provides support for namespace like C++. Without Namespace, we cannot declare two variables of same name. • C doesn't support the concept of constructors and destructors. Conclusion The C programming language doesn’t seem to have an expiration date. It’s closeness to the hardware, great portability and deterministic usage of resources makes it ideal for low level development for such things as operating system kernels and embedded software. Its versatility, efficiency and good performance makes it an excellent choice for high complexity data manipulation software, like databases or 3D animation. The fact that many programming languages today are better than C for their intended use doesn’t mean that they beat C in all areas. C is still unsurpassed when performance is the priority. The world is running on C-powered devices. We use these devices every day whether we realize it or not. C is the past, the present, and, as far as we can see, still the future for many areas of software.
0 notes
siva3155 · 6 years ago
Text
300+ TOP FORTRAN Interview Questions and Answers
Fortran Interview Questions for freshers experienced :-
1. What is Fortran? Explain Fortran stands for formula translation.Fortran is the first widely used high-level programming language. Fortran language is used for doing high-level scientific computing, and until today it is one of the widely used languages for this purpose. Fortran was release in the year 1957 which 62 years now. The popular language BASIC is based on Fortran II. 2. How should one spell FORTRAN/Fortran? FORTRAN is generally the preferred spelling for discussions of versions of the language prior to the current one (‘90”). Fortran is the spelling chosen by X3J3 and WG5. In this document a feeble effort has been made to capitalize accordingly (e.g. vast existing software ... FORTRAN vs. generic Fortran to mean all versions of the standard, and specifically the modern dialect, ISO 1539:1991). 3. How does Fortran 90 relate to FORTRAN 77? With a few minor exceptions, Fortran 90 is a superset of X3.9-1978 FORTRAN. But this does not mean that all ‘77” codes will port sans changes. Many (if not most) programmers employed constructs beyond the ‘77 standard, or rely on unspecified behavior (say, assuming that an OPEN of an existing file will position the file pointer to just past the last record already written) which has changed (that is to say, has become specified). 4. How do you use a logical variable? What is stored there? Most frequently, logical variables are used in association with IF statements. When you want to set a logical variable LVAR to true you use “LVAR=.TRUE.”. For false use “LVAR=.FALSE.” In practice the computer usually stores an integer( ) in memory for false and integer 1 for true. The normal logical variable occupies 1 byte of space. 5. Where can i get a Fortran Compiler for IBM PC? We can pick up one on the internet from the GNU project, but get a better package from MOC for about S80.00. 6. How do we know where various steps go in a Fortran program? Some commands have special locations, but most are located by the needs of the specific program. The PROGRAM card is always first Statements giving variable types (INTEGER, REAL, LOGICAL, CHARACTER) should precede “executable” statements. The END card must always be at the end of the program unit. 7. Why does not Fortran have intrinsic functions for something as simple as factorial? Two reasons. Factorial isn’t all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2? first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write “recursive functions”, but then you arejust fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don’t need an exact answer you can resort to Stirling’s Approximation. A Fortran statement that will load the value of this approximation into the variable nfact is. 8. What is the advantage of an array over a spreadsheet format? Both can store similar types of information m a neatly labeled and organized way. The advantage lies in where they are used. You have more control over how Fortran arrays are used than how the contents of a spreadsheet are used. In addition for any given operation on an array of numbers, once the Fortran is written, it will do the job much faster than a spreadsheet. On the other hand, when operations are not complex and computer execution time is not a problem using the spreadsheet is probably your best bet. 9. Do spaces mater in Fortran equations? No. Spaces are generally added for clarity Some compilers get upset if you write things like” INTEGERI,J” rather than INTEGER I,J”. Simple neatness will keep you out of these problems. Remember that a space is required in column 6 if you aren’t continuing from the previous line. The following are all equivalent: x=x*y**2*sin(x) x=x * y2 * sin(x) x= x * y**2 * sin ( x) 10. Why doesn't Fortran have intrinsic functions for something as simple as factorial? Two reasons. Factorial isn't all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2! first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write "recursive functions", but then you are just fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don't need an exact answer you can resort to Stirling's Approximation. A Fortran statement that will load the value of this approximation into the variable fact. 11. What is the advantage of an array over a spreadsheet format? Both can store similar types of information in a neatly labeled and organized way. The advantage lies in where they are used. You have more control over how Fortran arrays are used than how the contents of a spreadsheet are used. In addition for any given operation on an array of numbers, once the Fortran is written, it will do the job much faster than a spreadsheet. On the other hand, when operations are not complex and computer execution time is not a problem using the spreadsheet is probably your best bet. 12. How do you use a logical variable? What is stored there? Most frequently, logical variables are used in association with IF statements. When you want to set a logical variable LVAR to true you use "LVAR=.TRUE.". For false use "LVAR=.FALSE." In practice the computer usually stores an integer 0 in memory for false and integer 1 for true. The normal logical variable occupies 1 byte of space. 13. How do we know where various steps go in a Fortran program? Some commands have special locations, but most are located by the needs of the specific program. The PROGRAM card is always first. Statements giving variable types (INTEGER, REAL, LOGICAL, CHARACTER, ...) should precede "executable" statements. The END card must always be at the end of the program unit. 14. What is the difference between IF, THEN and DO WHILE statements. IF THEN combined with GO TO statements will let you do anything you want. The DO WHILE and other DO constructs allow you to loop through certain portions of code many times without ever writing GO TO statements. This makes coding slightly simpler, definitely clearer. 15. Where can I get a Fortran Compiler for an IBM PC? You can pick up one on the internet from the GNU project, but get a better package from MOC for about $80.00. 16. What is the difference between a Function Subprogram and a Subroutine? Some of the comments in the textbook are misleading on this subject. There are really only two differences. The biggest difference is that a subroutine never returns a value that is associated with its name. This means that you never need to declare a subroutine name in a type statement (REAL, INTEGER ...). All information coming back from a subroutine passes through the argument list, or something called a COMMON block (later). However, there is nothing in these communications channels that can't be used by a Function Subprogram. A secondary difference is that a Subroutine need not have an argument list. 17. What is the difference between DO, DO WHILE, and IF ( ) GOTO Loops. In terms of what the computer actually does, there is generally no difference. You can structure all three so that they do the same thing. When properly indented, the DO structures tend to be easier to follow. The DO WHILE structure can produce slightly more compact coding, combining a straight DO with the option for some extra comparison logic. In a vector and/or parallel computer, DO's send strong hints to the compiler that it should be looking for ways to feed a pipeline or spread calculations over multiple processors. 18. What can I do if my lines wrap around to the next line? You have to get a feel for the location of the 72nd character position on the screen, or do a lot ofcounting. Once you hit column 72, you must hit the RETURN key, put some character (I like & or #) in column 6 of the next line then pick up typing where you left off. I usually stop before column 72 at some natural break point between variables: 123456789012345678901234567890123456789012345678901234567890123456789012 IF ( (X.LT.2.0.AND.Y.GT.30.0).OR.(X.GT.1000.0.AND.Y.LT.-40.)) & PRINT *,' CALCULATION IS IN TROUBLE' Since Fortran tends to ignore blanks, the extra ones in the above 2 lines don't cause problems. 19. Can you give us a complete list of the Fortran commands and what they do? Sorry, but there are too many pages involved, and copyright problems with the standard Fortran manuals sold by computer software vendors. You're stuck with the text and Web pages, buying something else from a bookstore, or buying a Fortran package for your PC. 20. How can I format my output to look nicer (clear screen, double space, etc.) The best tools within Fortran are the in the FORMAT statement. "X" to add spaces in a line, and "/" to add blank lines on the output. Fortran doesn't know directly about your terminal type, so can't issue a specific screen clear command. You can brute force with "////////////////////////" (24 "/"'s) or call the Unix system as in the following example (note the extra call to get a listing of files after the screen is cleared). When clearing screens it is also useful to learn the Fortran "PAUSE" command to pause execution until you hit the RETURN (ENTER) key. Note that 'call system' is specific to the RS6000's. Other systems often have similar Unix connections. program test: call system('clear') call system('ls -alF') pause call system('whoami') end 21. What does "COMMON/CONTROL/ A, B, C" do to the values of A, B, C? It doesn't do anything to the values. It just establishes a place in memory for the values to be stored and retrieved. Every subroutine and function in your program that contains the line "COMMON/CONTROL/ A, B, C" will agree that operations using variables A, B, or C will get numbers from or put numbers in the same appropriate location in memory. That is, they agree that a reference to "A" means the same in all routines with common CONTROL, etc.. To give A, B, or C a value, you have two options. You can assign values at compilation time with a BLOCK DATA routine: BLOCK DATA ABCVAL COMMON/CONTROL/ A, B, C DATA A,B,C / 1.0, 2.0, 3.0/ END You can also assign and use values with executable statements. Say subroutines SUB1 and SUB2 contain this common block. If SUB1 contains the lines "A=1.0", and "B=2.0", and SUB2 has the line "C=A+B", then the value of C after this line in SUB2 is executed is 3.0. 22. What does "COMMON/CONTROL/ A, B, C" do to the values of A, B, C? It doesn't do anything to the values. It just establishes a place in memory for the values to be stored and retrieved. Every subroutine and function in your program that contains the line"COMMON/CONTROL/ A, B, C" will agree that operations using variables A, B, or C will get numbers from or put numbers in the same appropriate location in memory. That is, they agree that a reference to "A" means the same in all routines with common CONTROL, etc.. To give A, B, or C a value, you have two options. You can assign values at compilation time with a BLOCK DATA routine: BLOCK DATA ABCVAL COMMON/CONTROL/ A, B, C DATA A,B,C / 1.0, 2.0, 3.0/ END You can also assign and use values with executable statements. Say subroutines SUB1 and SUB2 contain this common block. If SUB1 contains the lines "A=1.0", and "B=2.0", and SUB2 has the line"C=A+B", then the value of C after this line in SUB2 is executed is 3.0. 23. Why doesn't Fortran have intrinsic functions for something as simple as factorial? Two reasons. Factorial isn't all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2! first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write "recursive functions", but then you are just fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don't need an exact answer you can resort to Stirling's Approximation. A Fortran statement that will load the value of this approximation into the variablenfact is: nfact = sqrt(2*3.1415963*n)*(n/2.71828)**n by 20! this has a 0.4% error. Try larger numbers on the machine for a better feeling of the approximation. 24. Do we need to prompt the user for input on our programs? Always! In this class, any programmed "read" from the terminal must be preceded by writing some intelligible message asking for input. 25. What directory is used by the compiler for compiling a Fortran Program? Where does f77 live? For the work in this class, you should assume that everything happens in whatever directory you are in when you type the "f77". Type "pwd" if you don't know the answer to this question. The executable file called "f77" resides both in /bin and /usr/bin on these machines. This is very unusual. To locate an executable file use the "whereis" command (e.g. "whereis f77"). Unfortunately the manual pages on f77 aren't connected properly and are listed under IBM's other name for their compiler, "xlf". Try "man xlf" for more information on the compiler, but don't expect too much. IBM likes to force people to buy manuals and special CD-ROM packages. 26. Why do you put so many lines of empty space in your programs? I hope the lines aren't totally empty. They should contain a "c" in column one. These "blank" lines are just to make the comments stand out from Fortran code lines or to highlight key blocks of a program. 27. Do spaces mater in equations? No. Spaces are generally added for clarity. Some compilers get upset if you write things like " INTEGERI,J" rather than INTEGER I,J". Simple neatness will keep you out of these problems. Remember that a space is required in column 6 if you aren't continuing from the previous line. The following are all equivalent: x=x*y**2*sin(x) x=x * y**2 * sin(x) x = x * y ** 2 * sin ( x ) 28. Is there any way to use variables in a format statement? Yes, but you have to use one format statement to build a second using a write to a character string. For example if you want to include the value of "n" as the number of real numbers per line you would do the following: PARAMETER (N=4) CHARACTER FORM1*16 REAL A(N,N) DO 10 I=1,N DO 10 J=1,N A(I,J)=J*100+I 10 CONTINUE WRITE(FORM1,2000)N 2000 FORMAT('(1X,',I3,'F6.1)') WRITE(6,FORM1) A STOP END Is it possible to lay out a two dimensional array with the double DO loops: DO 10 J=1,4 DO 20 K=1,4 A(J,K)=SUM(T(1:N)**(J+K-2)) 20 CONTINUE 10 CONTINUE yes, if you have a Fortran 90 compiler. 29. About CALL statements. Should they be within subroutines that they are calling for? Think of a CALL as a GO TO statement. If you say "CALL INPUT1", Fortran effectively looks for the statement called "SUBROUTINE INPUT1" and goes there to execute more instructions. Just before taking the jump, the program makes some notes so that the code in the SUBROUTINE knows about location of arguments, and knows that when it hits a RETURN statement, it should GO TO the statement in your code following "CALL INPUT1". You can see when thinking of this as a GO TO operation, there are too many opportunities for an infinite loop if SUBROUTINE INPUT1 contains a line that says "CALL INPUT1". There are also some subtle data management nightmares. To avoid all of this, older Fortran standards refused to let you include "CALL INPUT1" in SUBROUTINE INPUT1. This continues to be a good idea. However, for those who like to live on the edge Fortran 90 will let you include "CALL INPUT1" in SUBROUTINE INPUT1. This process is called recursion. I never use it, and don't recommend it. You will get another story from a certified Computer Scientist. Those folks really love recursion, and to be fair can do some fairly slick things with it. 30. Can you give us a complete list of the Fortran commands and what they do? No, but there are too many pages involved, and copyright problems with the standard Fortran manuals sold by computer software vendors. You're stuck with the text and Web pages, buying something else from a bookstore, or buying a Fortran package for your PC. 31. What does // do? It sticks 2 character strings together into a single string. If char1='file1.in' and char2='file2.out' then when char3=char1(1:5)//char2(6:9) the contents of char3 are 'file1.out' 32. What can I do if my lines wrap around to the next line? You have to get a feel for the location of the 72nd character position on the screen, or do a lot of counting. Once you hit column 72, you must hit the RETURN key, put some character (I like & or #) in column 6 of the next line then pick up typing where you left off. I usually stop before column 72 at some natural break point between variables: 123456789012345678901234567890123456789012345678901234567890123456789012 IF ( (X.LT.2.0.AND.Y.GT.30.0).OR.(X.GT.1000.0.AND.Y.LT.-40.)) & PRINT *,' CALCULATION IS IN TROUBLE' Since Fortran tends to ignore blanks, the extra ones in the above 2 lines don't cause problems. Explain Function Subprograms. What you have so far is just meant as an introduction. I'll be talking about them several more times during the semester. In the mean time, play with my example in newton3.f . It will get you safely through the homework. As an exercise try adding a second function at the end of the file called FUNCTION G(x), that sets G(x)=x4-2x2+1, and add lines in the main program to evaluate G(0), G(1), G(2) and print these values. 33. What does the function REAL(x) do? Not much if x is already a real variable. If x is and integer, the output of REAL is a real (floating point number with the same value. REAL(3) is 3.00000E+00. If x is a complex number REAL returns the real part (as opposed to the imaginary part) of x. 34. Is there a way to go back to the top of the error list after a failed compilation? The Unix script command will save things for you in a file. If you are running a terminal emulatorwith a "scroll bar" on the side of the window. Try clicking in the scroll bar to see old stuff. Most of you probably won't have that option, so try one of the following: f77 test.f >& testout f77 -qsource test.f The first dumps everything that would go to the screen (& picks up error messages which are treated as special cases by Unix) and puts the output into a file called "testout". It will complain and fail if "testout" already exists. The second will create a nice listing file called "test.lst" containing your source code and error messages. 35. If you use a BLOCK DATA statement to initialize a common block, do you lose the advantage of a smaller executable file? No, and Yes. You don't lose anything because the disk space advantage was already gone when you decided to use the named common blocks rather than blank common. BLOCK DATA will only assign values to contents of named common blocks. The disk space decision takes place when you choose to place variables in named common or blank common. Please remember that you can have lots of different named common blocks, but there is only one blank common block. 36. When is the common command not used correctly in a Fortran Statement? You're asking for quite a bit here. There are lots of ways to introduce errors. The most obvious is to try inserting a common in the midst of executable statements. It belongs up with DIMENSIONs, PARAMETER's, SAVE's, and the rest of the non-executables. A more subtle problem is the use of multiple COMMON statements for blank common or the same named common. Fortran will accept the following program: program testcom common a,b common c,d a=1.0 b=2.0 c=3.0 d=4.0 call sub1 stop end subroutine sub1 common c,d print *, c, d return end However, the values printed out are 1.0 and 2.0. The second common statement in the main program just tacks the variables "c" and "d" onto blank common after "b". The two commons together are equivalent to "common a,b,c,d". In the subroutine you are saying that "c" is the first element in blank common, so Fortran associates "c" in "sub1" with the same address in memory as assigned to "a" in the main program. Also recall that mixing reals and integers (common/blk1/a,b,i,c) when the reals are double precision may cause errors on some machines, and is not a good idea on any 32 bit machine. 37. If you're eventually going to use X(1:N) with a chosen N what's the point in using X(*)? Given what you know now, no point at all. If N is available to me in the argument list, I would generally use "REAL X(N)" rather than "REAL X(*)". Two exceptions to this. If I pass N as an argument to give the range of a DO loop associated with X, but also make a special reference to X(N+1) later in the subroutine, I would use "X(*)" to note that the array is really longer than N. Some smart compilers will force me to do this. The second exception is related to Fortran 77. As mentioned below, I can pass N to my subroutine through a COMMON block and not include it in the argument list. If that is how I do it, pure Fortran 77 won't accept "REAL X(N)", and I'm stuck with "REAL X(*)". Fortran 90 and most late model improved Fortran 77 compilers will permit "REAL X(N)" when N is in a COMMON block. 38. What's the use of a blank common as opposed to a common with a name? The major use is in cutting the size of the executable file produced by "f77" (usually a.out). It won't seem like a big deal to you now, but in applications containing many arrays with thousands to millions of elements each, this can make a huge difference in the amount of disk space you soak up. A secondary use is that, when the program starts, the space finally allocated to blank common in memory is at the very end of the program. If you are tricky enough, you can take advantage of this to dynamically extend the size of a single array in blank common as your space requirements grow during execution. 39. If we write a subroutine for someone else, how can we compile it to see if it will run before giving it to them? This question gets to the heart of good programming practices. I'll give you an introduction here, and emphasize some of these points in later lectures. The easy part of the answer was hidden in the demonstration where I compiled 2 parts of a program separately and made a program on the 2nd partial compile. If you make a subroutine in a file called "subr1.f", you can compile to just test for Fortran errors with the command "f77 -c subr1.f". The "-c" option says just go through the compilation steps but don't make an executable code for me. This will leave a file behind called "subr1.o", which is almost machine instructions, and is ready to be linked to other stuff to make a full program. You're really not done yet. You should write a very short driver main program, that feeds some numbers to subr1 (call subr1(...)) for which you know the returned answer. You thencheck the known answers against the subroutine's answers before declaring victory. This testing is often easier said than done. Most useful subroutines do some fairly complicated calculations and contain IF tests that can result in different options being used depending on the input conditions. Designing test cases and checking methods can be challenging, but is essential. When approached systematically, this testing process is science at its best. You are in the business of constructing and interpreting controlled experiments. When using computers, most people simply treat them as an extension to theoretical science, another way to solve some equations. By recognizing the organized experimental aspects of creating and using computer programs you can give yourself a competitive advantage in this business. 40. What is the advantage of an array over a spreadsheet format? Both can store similar types of information in a neatly labeled and organized way. The advantage lies in where they are used. You have more control over how Fortran arrays are used than how the contents of a spreadsheet are used. In addition for any given operation on an array of numbers, once the Fortran is written, it will do the job much faster than a spreadsheet. On the other hand, when operations are not complex and computer execution time is not a problem using the spreadsheet is probably your best bet. 41. How do we know where various steps go in a Fortran program? Some commands have special locations, but most are located by the needs of the specific program. The PROGRAM card is always first. Statements giving variable types (INTEGER, REAL, LOGICAL, CHARACTER, ...) should precede "executable" statements. The END card must always be at the end of the program unit. 42. When accessing a data file in a program can I change directories? Yes if you have a subdirectory called "test" under the location that your program, you can open the file "my.data" in "test" for reading on unit 11 with the command: OPEN(11,file='test/my.data') 43. Subprograms. What do they do and how do the help program. They do anything that the main program can do. They help you organize your total program (main program + subprograms) by grouping specific tasks in a well defined location. They can save you repeating similar program structures at several places in your code. Also, for many tasks someone has already written a subprogram to do the job and you save a lot of work by picking up their subprogram and plugging it into your work. You will see an example of this when we start solving systems of linear equations (say 10 equations and 10 unknowns). You will define the equations, then let somebody else's subprogram solve them. 44. How do we know where various steps go in a Fortran program? Some commands have special locations, but most are located by the needs of the specific program. The PROGRAM card is always first. Statements giving variable types (INTEGER, REAL, LOGICAL, CHARACTER, ...) should precede "executable" statements. The END card must always be at the end of the program unit. 45. Could you give us sample questions on determining output of code containing recent commands? DIMENSION A(5),B(5),C(5) DATA A/1.,2.,3.,4.,5./,B/5*2/,C/5*0.0/,IMIN,IMAX,ISTEP/2,5,2/ DO 100 I=IMIN,IMAX,ISTEP 100 C(I)=A(I)*B(I) WRITE(6,2000) I,(C(J),J=1,5) 2000 FORMAT(' I=',I5,' C=',/, (1P,4E15.7)) STOP END What is the value of "I" printed out. What are the values of "C" printed? Also check my sample "essay" question on the back of this handout. 46. When accessing a data file in a program can I change directories? Yes if you have a subdirectory called "test" under the location that your program, you can open the file "my.data" in "test" for reading on unit 11 with the command: OPEN(11,file='test/my.data') 47. What a DATA statement does. It simply puts a specific value into a Fortran variable. "DATA A/1.0/" is the same as "A=1.0" in terms of results. The only difference is that the DATA statement sets A to 1.0 before the program starts to execute. The biggest advantage occurs when you are trying to give a variable a value in a FUNCTION or SUBROUTINE that is used a large number of times. The program on the left is faster than the program on the right below. Do 100 i=1,1000000 do 100 i=1,1000000 100 y(i)=addon(x(i)) 100 y(i)=addon(x(i)) stop stop end end function addon(x) function addon(x) data b/1.12345/ b=1.12345 addon=x+b addon=x+b return return end end Yes, its a stupid example, but applies to real programs. 48. Can more than one variable be stored in a Data Statement? Yes. For example you can set initial values for A, B, and C with either of the following statements. DATA A/1.0/,B/2.0/,C/3.0/ DATA A,B,C/1.0,2.0,3.0/ About the exact use of arrays and their purpose The simple answer is "pay attention to the lectures and examples for the rest of the semester." Arrays are used when you have a large number of numbers on which you want to do identical or similar analysis. Let's say I have the temperature and pressure from 10,000 measuring stations in the US, and want to calculate the air density at each of these points. I load the temperatures and pressures into arrays with a dimension of 10000, and pair by pair I march through and evaluate a function to give density in another array. dens(i)=rho(t(i),p(i)) Yes, I could have read the data in a pair at a time and printed results one line at a time without using an array. However, what if this is just the beginning? What if I'm going to take all off my temperatures, pressures, densities and several other measurements from each station and use it as part of a complicated calculation to predict the weather for the next 24 hours? I have to keep all of the data in the computer. Arrays provide a convenient way of storing and retrieving all of this information within a program. Please note that while the program is executing, information contained in arrays, like other Fortran variables, is kept in the machine memory where access times are much faster than when the information is in a disk file. 49. Could you go over colons again in dealing with arrays? Within Fortran 77 there is only one use for colons associated with arrays, and that is when establishing the size and permitted range of indices in a DIMENSION or type (REAL, INTEGER, ...)statement. For example "DIMENSION A(-4:10)" assigns 15 words of memory to the array A, and makes a note that A(-4) corresponds to the first of these sequential words. For Fortran 90 using a colon within an executable statement is just shorthand for writing a DO loop involving just one line. C(1:9)=A(1:9)+B(1:9) is the same as: DO 100 I=1,9 100 C(I)=A(I)+B(I) C(1:9:2)=A(1:9:2)+B(1:9:2) is the same as DO 100 I=1,9,2 100` C(I)=A(I)+B(I) Write a few 5-10 line programs until you are comfortable with how this behaves. 50. Are We Actually Going to Need Character Variables? Why are they used? You could probably get through all of the programming applications in this class without resorting to character variables. However, if you are going to create programs with legible output and/or flexible input/output you will need them. You have already seen me use them to store names of files for use in input (look at the sample program trig3.f). That is one of the most common uses for simple programs. Also, take a look at the tricks I play in plot1.f and plot2.f to generate creative output with the help of character variables. When you start driving graphics subroutines to view your data, you will find that character variables a useful and generally mandatory. Postscript: My daughter (Senior, physics) burst out laughing when she saw this question while trying to throw me off of the family PC. Yes, she is cruel, but her experience may be closer to what you will use soon than the crazy things that I do. She is doing quite a bit of Fortran programming for Dr. Garrison in the Chem department. She says she couldn't get along without charactervariables to keep track of file names and manage printed and graphical output. 51. What directory is used by the compiler for compiling a Fortran Program? Where does f77 live? For the work in this class, you should assume that everything happens in whatever directory you are in when you type the "f77". Type "pwd" if you don't know the answer to this question. The executable file called "f77" resides both in /bin and /usr/bin on these machines. This is very unsual. To locate an executable file use the "whereis" command (e.g. "whereis f77"). Unfortunately the manual pages on f77 aren't connected properly and are listed under IBM's other name for their compiler, "xlf". Try "man xlf" for more information on the compiler, but don't expect too much. IBM likes to force people to buy manuals and special CD-ROM packages. 52. How do you use a logical variable? What is stored there? Most frequently, logical variables are used in association with IF statements. When you want to set a logical variable LVAR to true you use "LVAR=.TRUE.". For false use "LVAR=.FALSE." In practice the computer usually stores an integer 0 in memory for false and integer 1 for true. The normal logicalvariable occupies 1 byte of space. 53. Do spaces mater in equations? No. Spaces are generally added for clarity. Some compilers get upset if you write things like " INTEGERI,J" rather than INTEGER I,J". Simple neatness will keep you out of these problems. Remember that a space is required in column 6 if you aren't continuing from the previous line. The following are all equivalent: x=x*y**2*sin(x) x=x * y**2 * sin(x) x = x * y ** 2 * sin ( x ) 54. Why are go to statements bad, and what can we do to avoid them? GO TO is bad only to the extent that it makes coding difficult to read. I think they are an important part of the language, but should be used sparingly. Use of DO loops and IF, THEN, ELSE constructs (along with good indentation habits) whenever practical will take care of most of the problem. In extreme cases where you have many nested IF statements, with many lines contained in each THEN/ELSE option set, even good indentation habits will not improve code clarity. Consider breaking code off into subroutines, or go back to GOTO constructs where you can at least trace labelnumbers with an editor. 55. Why do you put so many lines of empty space in your programs? I hope the lines aren’t totally empty. They should contain a “c” in column one. These “blank” lines are just to make the comments stand out from Fortran code lines or to highlight key blocks of a program. 56. What are the Array Intrinsic Functions available in Fortran? The Array Intrinsic Functions available in Fortran are: Inquiry Reshape Location Reduction Construction Manipulation Vector and matrix multiplication 57. What are the commonly used character functions in Fortran? The commonly used character functions in Fortran are: len(string) index(string,sustring) achar(int) iachar(c) trim(string) scan(string, chars) verify(string, chars) adjustl(string) adjustr(string) len_trim(string) repeat(string,ncopy) 58. What are the types of intrinsic data types of Fortran? There are five types of intrinsic data types are: Real type Integer type Complex type Logical type Character type Fortran Questions and Answers Pdf Download Read the full article
0 notes
douchebagbrainwaves · 8 years ago
Text
WORK ETHIC AND MEDIOCRE
But if you think about it, because that means we're going to try to do it. College is where faking stops working. Independently wealthy This is my excuse for not starting a startup right out of stock that has some additional rights over the common stock everyone else has overlooked. The reason the filters caught them was that both companies in January switched to commercial email senders instead of sending the mails from their own; and its very uselessness made it function like white gloves as a social bulwark. Out in the real world, nerds collect in certain places that specialize in it—that you can write it and push it to the solid ground on the other side of this coin is that it's more straightforward. Well, that may seem an odd question to ask about a field is how honest its tests are, because it's by doing that. Not any more. I know when we started Y Combinator we sometimes mistakenly fund teams who have the balls to turn down most acquisition offers. Writing mainframe software required too much commitment up front. Merely incorporating yourselves isn't hard.
If angels are so important, can we use one field's discoveries about beauty to help us in another? I calculate as follows: continuation 0. Hardware startups face an obstacle that software startups don't. When you look at the machinery of fashion and try to buy some. Nor is it necessary for a startup founder. And the reason is prestige. One thing that might deter you from going to grad school after this equivocal recommendation, I can tell, the founders are young.
The most valuable way to approach the current philosophical tradition may be neither to get lost in pointless speculations like Berkeley, nor to shut them down like Wittgenstein, but to learn and do. Who wants this so much that this is so, because the main way to spend money even for something important, like going to the site and buying something? But in fact there will be less and less money, because a that's not what you're trying to remember as you start to think for themselves. Phrased that way, you'd be less than a good programmer makes in salary in Silicon Valley. If I'd had to wait till his arteries were over 90% blocked and 3 days later he had a quadruple bypass. Only a few people think in our insular little Web 2. There is one other language still surviving from the 1950s, Fortran, and it might be wise to give him. Surely that's mere prudence?
A nerd looks at that deal and sees only: pay a fortune for mediocre software. The 'riting component of the antidote is chance meetings with people who can solve tedious system-administration type problems for them, shrinking from the work experience employers consider so desirable. And when you do have real effects, it's no longer enough to protect hunter-gatherers, and perhaps even dangerous tests to resolve. This argument applies to every aspect of his life. The distinction between expressions and statements. Can anything break this cycle? If you don't genuinely believe that, perhaps you ought to try to make it look fast. No one trusts an idea till you embody it in a second: they make bad cars. This concept is a simple yes, but the way he composed them into molecules was near faultless. But by the time I couldn't imagine why there should be any lower limit for the age of the company. It's due to the creators of past gadgets that gave the company a reputation for being valuation sensitive and can postpone dealing with them till last, but occasionally one you didn't know about the stuff they've invested in.
How can you get errors asking that? Another thing you notice when you see something that's merely reacting to new technology, Revenue Loop. We got one paper to print this number, which seemed intolerably déclassé to a high-tech startup is almost redundant. Hear no till you hear yes. If you don't understand, and more informal. And then of course it's worth being wise. Only those that are rough with them. But any application can be interesting if it poses novel technical challenges. 3 networks offered were indistinguishable. The biggest difference is that in order to reach a few gullible people the spammer sends mail to everyone.
Someone has an idea in the harsh light of morning and ask: will people actually pay for this? With a desktop application. Airbnb is that kind of works. When you judge people that way, who can more easily be replaced. Spam filter wouldn't have caught it. Subject free FREE! The term angel round doesn't mean that it's a pretty cheesy trick—one of the sort that relies on pushing a few visual buttons really hard to temporarily overwhelm the viewer. If you ask eminent people what's wrong with their lives, there was a version half the size of series A rounds with no loss of quality. We are still very rare. More powerful programming languages make programs shorter. The same is true in the military—that the earth moves.
So when you're not working on everything else. I could, and even though I've studied the subject for years, and then after generating interest there, ask more prestigious VCs for larger amounts, and the top management jobs. Which means the ambitious can now do arbitrage on them. There was something else I wanted more: to be smart: from their parents to start a startup at 30. Incidentally, nothing makes it more discriminating. Which is to say that ambition is a component of it, you should take money from people who are committed enough to prefer that, and they offer leverage because they make such great stuff, but that you can. Without exception the high-end product; don't let your code get too big, they become overwhelmed.
It doesn't make a product. In this respect, as in so many areas of technology. But in fact if you narrow the definition of a token. At the other extreme you work at something that pays the bills too, even though the other things they would like that would be the first time investors learned that lesson from founders. People there are trying to do real work. They don't have time for your ideas to evolve, because the companies themselves had become sclerotic. Stuff has gotten a lot cheaper. And anyone who makes the same point: that it can't have been heredity, because it requires a deliberate choice. We'll find out this winter.
Notes
Learning this explained a lot of people who are running on vapor, financially, and Reddit is Delicious/popular is driven mostly by hackers. Unfortunately the payload can consist of dealing with one of the world wars to say, ending up on the LL1 mailing list.
The second part of their initial attitude. Some people still get rich simply by being energetic and unscrupulous, but Google proved them wrong.
Put rice in rice cooker, if the selection process looked for different reasons. And at 98%, as it sounds like the difference directly.
0 notes